/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package assignment_cp3120.administrator.editmanager;

import assignment_cp3120.user.registeruser.RegisterUserView;
import assignment_cp3120.ucm.UC2AL;
import assignment_cp3120.ucm.UCEditManager;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;

/**
 *
 * @author Administrator
 */
public class EditManagerView extends RegisterUserView{
    private EditManagerModel model;
    private CancelButtonAL cAL;
    private UC2AL sAL;
    
    public EditManagerView() {
        this(new EditManagerModel());
    }
    public EditManagerView(EditManagerModel model) {
        this.model = model;
        super.clearButtonAL();
        
        cAL = new CancelButtonAL();
        sAL = new UC2AL(new UCEditManager(this.model,this));
        setButtonAL();
    }
    
    @Override protected void clearButtonAL() {
        cancelButton.removeActionListener(cAL);
        submitButton.removeActionListener(sAL);
    }
    @Override protected void setButtonAL() {
        cancelButton.addActionListener(cAL);
        submitButton.addActionListener(sAL);
    }
    private class CancelButtonAL implements ActionListener{
        public void actionPerformed(ActionEvent e) {
            hideGUI();
        }        
    }
    public void notManagerMessageBox() {
        message(null,"The given username is not a Manager. User can only edit themselves and " +
                "Administrators cannot be edited via this program",
        "System privilage error",
        JOptionPane.ERROR_MESSAGE);
    }
    public void message(Component parentcomponent,
            Object message,
            String title,
            int messageType ){            
        JOptionPane.showMessageDialog(parentcomponent,message,title,messageType);
    }
}
